<?php
/*
Plugin Name: Global Translator - Widgetized
Plugin URI: http://www.diarioaborbo.com/plugin-wordpress/multilanguage-translator-widget/
Description: Widgetized version of plugin <a href="http://www.nothing2hide.net/blog/2006/08/20/wordpress-global-translator-plugin/">Global Translator</a> and <strong>it is required to have activated it</strong>.
Author: Luis P&eacute;rez (cinefilo)
Version: 1.1
Author URI: http://www.diarioaborbo.com


  Copyright (c) 2006 by Luis Perez (cinefilo) (email : cinefilo@gmail.com) 
  
  http://www.gnu.org/copyleft/gpl.html

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Credits

This widget use Multilanguage Translator plugin version 0.3 released by Davide Pozza [http://www.nothing2hide.net/blog/2006/08/20/wordpress-global-translator-plugin/].

Changelog:

	- v1.1 (05-10-2006): Add credits.
	- v1.0 (29-08-2006): Initial released.

 */


function widget_global_translator_init() {

	if ( !function_exists('register_sidebar_widget') )
		return;

	function widget_global_translator($args) {

		extract($args);

		$options = get_option('widget_global_translator');
		$title = $options['title'];

		if (function_exists('build_flags_bar')){
			echo $before_widget . $before_title . $title . $after_title;
			build_flags_bar();
			echo $after_widget;
		}
	}

	function widget_global_translator_control() {

		$options = get_option('widget_global_translator');
		if ( !is_array($options) )
			$options = array('title'=> '');
		if ( $_POST['global_translator-submit'] ) {

			$options['title'] = strip_tags(stripslashes($_POST['global_translator-title']));

			update_option('widget_global_translator', $options);
		}

		$title = htmlspecialchars($options['title'], ENT_QUOTES);
		
	?>		
	<p><label for="global_translator-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="global_translator-title" name="global_translator-title" type="text" value="<?php echo $title; ?>" /></label></p>
	<input type="hidden" id="global_translator-submit" name="global_translator-submit" value="1" />
<?php		
	}

	register_sidebar_widget('Global Translator ', 'widget_global_translator');
	register_widget_control('Global Translator ', 'widget_global_translator_control', 300, 100);
}

add_action('plugins_loaded', 'widget_global_translator_init');

?>
